package prictice.hbase.state;

import org.apache.storm.trident.state.*;

import java.util.HashMap;
import java.util.Map;


/**
 * @Package prictice.hbase.state
 * @Description:
 * @Author elwyn
 * @Date 2017/9/21 22:36
 * @Email elonyong@163.com
 */
public class TridentConfig<T> extends TupleTableConfig {

    private static final long serialVersionUID = 257375474298793181L;
    private int stateCacheSize = 1000;
    private Serializer serializer;

    public TridentConfig(String tableName, String tupleRowKeyField) {
        super(tableName, tupleRowKeyField);
    }

    public TridentConfig(String tableName, String tupleRowKeyField, String tupleTimestampField) {
        super(tableName, tupleRowKeyField, tupleTimestampField);
    }

    public static final Map<StateType, Serializer> DEFAULT_SERIALIZES = new HashMap<StateType, Serializer>() {
        private static final long serialVersionUID = 8728692674320298324L;

        {
            put(StateType.NON_TRANSACTIONAL, new JSONNonTransactionalSerializer());
            put(StateType.TRANSACTIONAL, new JSONTransactionalSerializer());
            put(StateType.OPAQUE, new JSONOpaqueSerializer());
        }
    };

    public int getStateCacheSize() {
        return stateCacheSize;
    }

    public void setStateCacheSize(int stateCacheSize) {
        this.stateCacheSize = stateCacheSize;
    }

    public Serializer getSerializer() {
        return serializer;
    }

    public void setSerializer(Serializer serializer) {
        this.serializer = serializer;
    }
}
